package com.milk.nettylearn.protocol;

import com.milk.nettylearn.message.LoginRequestMessage;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

public class TestMessageCodeC {
    public static void main(String[] args) throws Exception {
        MessageCodec messageCodec = new MessageCodec();
        EmbeddedChannel channel = new EmbeddedChannel(new LoggingHandler(LogLevel.DEBUG), messageCodec);

        LoginRequestMessage loginRequestMessage = new LoginRequestMessage("nihao", "wohao");
        channel.writeOutbound(loginRequestMessage);

        ByteBuf buf = ByteBufAllocator.DEFAULT.buffer();
        messageCodec.encode(null,loginRequestMessage, buf);
        channel.writeInbound(buf);
    }
}
